package com.itheima.aspect;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

//@Aspect // 标识当前类是切面类
//@Component
@Slf4j
public class RecordTimeAspect {

    // 切入点表达式
    @Around("execution(* com.itheima.service.DeptService.*(..))")
    public Object recordTime(ProceedingJoinPoint pjp) throws Throwable {
        long start = System.currentTimeMillis();

        Object result = pjp.proceed();

        long end = System.currentTimeMillis();
        log.info("执行耗时：{}ms", end - start);

        return result;
    }
}
